package
{
	import com.util.TestButton;
	
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.TextField;
	
	import leaf.science.Global;
	import leaf.science.ui.featuresflayer.FeaturesPlayer;
	
	
	[SWF(frameRate="30", backgroundColor="#ECECEC", width="1024", height="680")]
	public class FeaturesTest extends Sprite
	{
		private var _field:TextField;
		private var _loader:Loader;
		private var _list:XMLList;
		private var _count:uint;
		public var featPlayer:FeaturesPlayer;
		
		public function FeaturesTest()
		{
//			_field = new TextField();
//			addChild(_field);
//			
//			var format:TextFormat = new TextFormat('verdana', 11, 0x454444);
//			format.leading = 2;
//			
//			_field.selectable = false;
//			_field.defaultTextFormat = format;
//			_field.width = 230;
//			_field.height = 340;
//			_field.x = 450;
//			_field.y = 30;
//			
//			_field.multiline = true;
//			_field.wordWrap = true;
//			_field.condenseWhite = true;
//			
//			_loader = new Loader();
//			addChild(_loader);
//			_loader.x = _loader.y = 30;
//			
			
			featPlayer = new FeaturesPlayer();
			featPlayer.x = 512;
			featPlayer.y = 340;
			addChild(featPlayer);
			
			featPlayer.open();
			
			_count = 0;
			_list = Global.DATA_FEATURES..feature;
			
			next();
			
			var testBtn:TestButton = new TestButton("Next");
			addChild(testBtn);
			testBtn.onClick = next;
			
			var testBtn2:TestButton = new TestButton("Open");
			testBtn2.y = 40;
			addChild(testBtn2);
			testBtn2.onClick = featPlayer.open;
			
			
		}
		
		private function next (evt:Event = null):void
		{
			if (!featPlayer.isOpen) featPlayer.open();
			var feat:XML = _list[_count];
			
			
			featPlayer.data = feat;
			
			
//			var s:String = StringUtils.removeExtraWhitespace(feat.text.toString())
//			_field.htmlText = s;
//			
//			_loader.load(new URLRequest('../image/features/'+feat.image));
			
			_count = (_count < _list.length()-1) ? _count + 1 : 0;
		}
		
	}
}
